**************************************
*generated: 2023-05
*
*by Lukas Rudolph
*
*modified: 
*
*Data used:  arms_conjoint_TabA6.dta

*Tables generated: TabA6.tex
*Figutes generated: -- 
**************************************


********************************************************
*prep stata
********************************************************

*findit estout // install estout Package by Benn Jann
version 17

*set working directory to replication dataset folder

********************************************************
*LOAD DATA
********************************************************

/*
**from arms_conjoint.RDS create file for Stata to importance

**reduce this file to the variables needed for Table A6
keep uuid Q20B ParteDisplay_DE ParteDisplay_FR VIGNETTE Q13 Q13 Q13_FR Q13_FR Q17 y_rating CH CJ

**save this file
save "data/arms_conjoint_TabA6.dta", replace
*/

*subsequently work with this data (or start with this data from start)
use "data/arms_conjoint_TabA6", clear


********************************************************
*PREPARE DATA FOR TABLE A6
********************************************************

**
*generate variable for vignette treatment conditions
recode VIGNETTE (1 5 = 1 "high value, autocracy") (2 6 = 2 "low value, autocracy") (3 7 = 3 "high value, democracy") (4 8 = 4 "low value, democracy"), gen(treat)

**
*generate indicator for all respondents that reject, i.e., score A) at or below 3 in all conjoint rating tasks as well as reject arms trade in the vignette; score B) at 1 in all conjoint rating tasks as well as reject arms trade in the vignette

bysort uuid: egen maxrating = max(y_rating)
gen ratingmax3 = maxrating <= 3
gen ratingmax1 = maxrating <= 1
gen rejectormax1 = ratingmax1
gen rejectormax3 = ratingmax3
replace rejectormax3 = 0 if Q17==1
replace rejectormax1 = 0 if Q17==1

**
*generate indicator whether respondent was displayed his PID party yes (=1) or any other party (=0) for evaluating parties

gen sameparty = 0
replace sameparty = 1 if ParteDisplay_DE == Q13 & Q13 < 7
replace sameparty = 1 if ParteDisplay_FR == Q13_FR & Q13_FR < 9


**
*label variables
label variable treat "Vignette treatment conditions"
label variable rejectormax3 "Deontologist resp. (max. rating 3)"
label variable rejectormax1 "Deontologist resp. (max. rating 1)"
label variable sameparty "PID party evaluated"
label variable Q20B "Issue importance"


********************************************************
*RUN REGRESSION
********************************************************
*thereby: use only one observation per respondent with if CH=="CH1" & CJ == "CJ1" 

eststo clear
eststo: reg Q20B i.sameparty##i.rejectormax1 if CH=="CH1" & CJ == "CJ1"  
eststo: reg Q20B i.sameparty##i.rejectormax1 i.treat  if CH=="CH1" & CJ == "CJ1"  
eststo: reg Q20B i.sameparty##i.rejectormax3  if CH=="CH1" & CJ == "CJ1"  
eststo: reg Q20B i.sameparty##i.rejectormax3 i.treat if CH=="CH1" & CJ == "CJ1"  

esttab  ///
, stats(N r2) noomitted nobase se rename(1.rejectormax1 1.rejectormax3 1.sameparty#1.rejectormax1 1.sameparty#1.rejectormax3 ) label ///
mgroups("Rejector w/ maxrating = 1" "Rejector w/ maxrating = 3", pattern(1 0 1 0)) replace compress ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


********************************************************
*EXPORT TABLE
********************************************************

esttab using "tabs\tab_a_6.tex" ///
, stats(N r2) noomitted nobase se rename(1.rejectormax1 1.rejectormax3 1.sameparty#1.rejectormax1 1.sameparty#1.rejectormax3 ) label ///
mgroups("Rejector w/ maxrating = 1" "Rejector w/ maxrating = 3", pattern(1 0 1 0)) replace compress ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


***// END OF FILE //***